// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios';
import VueCookies from 'vue-cookies';
import { DatePicker } from 'view-design';
import 'view-design/dist/styles/iview.css';

Vue.use(VueCookies)
Vue.use(ElementUI);
// 日历插件
Vue.component('DatePicker', DatePicker);
Vue.config.productionTip = false;

// 挂载到 vue
// Vue.prototype.HOST = 'localhost:9999';
Vue.prototype.AXIOS = axios;
Vue.prototype.COOKIE = VueCookies;

// 做一个全局拦截器, 如果遇到 error, 就返回 login
axios.interceptors.response.use((resp) => {
    return resp; //别忘了返回
}, (error) => {
    console.log(error)
    VueCookies.remove("is_login");
    VueCookies.remove("token");
    VueCookies.remove("uid");
    VueCookies.remove("name");
    VueCookies.remove("role_id");
    router.push({path: "/login"});
    return Promise.reject(error)
})


/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
